#include "delay.h"

static void setTim(MyTim *timer,uint32_t delayms)
{
    timer->start = HAL_GetTick();  
    timer->delay = delayms;
}

static uint32_t compareTim(MyTim *timer)
{
    if(HAL_GetTick() - timer->start >= timer->delay)
    {
        return 1; //返回1说明达到了定时要求	
    }else
    {
        return 0; 
    }
}	

void bareDelay(uint32_t ms)
{
    MyTim timer;
    setTim(&timer, ms);
    while(!compareTim(&timer));
}
